package demo01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        //使用HashSet集合存储学生对象
        HashSet<Student> hs = new HashSet<>();
        hs.add(new Student("张三", 23));
        hs.add(new Student("张四", 26));
        hs.add(new Student("张五", 30));

        //普通迭代器
        Iterator<Student> it = hs.iterator();
        while (it.hasNext())
            System.out.println(it.next());

        System.out.println("--------------------");
        //增强for
        for (Student temp : hs)
            System.out.println(temp);
    }

}
